<?php
class UserAction extends Action{
     function _initialize(){
         if(!isset($_SESSION[C('USER_AUTH_KEY')])){
             $this -> redirect('login', 'Public');
             }
         parent :: _initialize();
         }
     public function index(){
         $user = D("User");
         $userId = $_SESSION[C('USER_AUTH_KEY')];
         $user -> find("{$userId}");
         $this -> assign("uid", $userId);
         $this -> assign("account", $user -> account);
         $this -> assign('mobilephone', $user -> mobilephone);
         $this -> assign('qq', $user -> qq);
         $this -> assign('email', $user -> email);
         $this -> assign('bankname', $user -> bankname);
         $this -> assign('bankadd', $user -> bankadd);
         $this -> assign('bankuser', $user -> bankuser);
         $this -> assign('creditcard', $user -> creditcard);
         $this -> display();
         }
    
     public function update(){
         $model = D("User");
         if(false == $model -> create()){
             $this -> error($model -> getError());
             }
         if("" == $_POST['password']){
            
             $data['id'] = addslashes($_POST['id']);
             $data['account'] = addslashes($_POST['account']);
             $data['qq'] = $_POST['qq'];
             $data['mobilephone'] = $_POST['mobilephone'];
             $data['creditcard'] = addslashes($_POST['creditcard']);
             $data['bankname'] = addslashes($_POST['bankname']);
             $data['bankadd'] = addslashes($_POST['bankadd']);
             $data['bankuser'] = addslashes($_POST['bankuser']);
             $result = $model -> save($data);
            
             }else{
             $result = $model -> save();
             }
         if($result){
             // 成功提示
            $this -> success(L('_UPDATE_SUCCESS_'));
             }else{
             // 错误提示
            $this -> error(L('_UPDATE_FAIL_'));
             }
         }
     }

?>